Numpy

Installation

pip install numpy

For plotting we will use matplotlib

pip install matplotlib


pip install numpy matplotlib python-opencv

Matrix Operations

source)

1 - Add

image.png

Using numpy to add 2 numbers source

2 - Scalar Dot Matrix

image.png

Using numpy dot function source

3 - Transpose Matrix

image.png

4 - Matrix Multiplication

image.png

image.png

image.png

4 - Linear equations

image.png

image.png

Linear Operations

Disclaimer source

Linear Transformation

Scaling the plane in the x-axis by a factor of 1.5

image.png

Dilating the plane by a factor of 1.8

image.png

Dilating the plane by a factor of 0.5

image.png

Scaling the plane in the y-axis by a factor of 0.5

image.png

Shearing about the y-axis with a vertical displacement of +x/2

image.png

Rotation through 45∘ about the origin

image.png

Reflexion in a line with inclination of 45∘ through the origin

image.png

If you remember the slides from the last life


image-2.png

image.png

The first library to computer vision in OpenCv

OpenCV was started at Intel in 1999 by Gary Bradsky, and the first release came out in 2000. Vadim Pisarevsky joined Gary Bradsky to manage Intel's Russian software OpenCV team. In 2005, OpenCV was used on Stanley, the vehicle that won the 2005 DARPA Grand Challenge. Later, its active development continued under the support of Willow Garage with Gary Bradsky and Vadim Pisarevsky leading the project. OpenCV now supports a multitude of algorithms related to Computer Vision and Machine Learning and is expanding day by day.

OpenCV-Python OpenCV-Python is a library of Python bindings designed to solve computer vision problems.

basic operations using openCV

Pyimage search is once of the best resources for learning computer vision stuff source

The following code is from Pyimage search source

image.png

Syntax

cv2.imread("/path/to/image", flag)

(height, width, number_of_channels)

source

Color Space

Various color spaces such as RGB, BGR, HSV can be mutually converted using OpenCV

Resize Image

image.png

cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]])

image.png

What is a pixel

All images consist of pixels which are the raw building blocks of images. Images are made of pixels in a grid. A 640 x 480 image has 640 columns (the width) and 480 rows (the height). There are 640 * 480 = 307200 pixels in an image with those dimensions.

Pixel Can Be

source

image.png

Drawing

rectangle(image, top_left_pixel_location, bottom_right_pixel_location, rectangle_color, thickness)
cv2.circle(image, center_of_circle, circle_radius, circle_color, thickness)
cv2.line(image, top_left_pixel_location, bottom_right_pixel_location, line_color, thickness)
cv2.putText(img, text, starting_point, font_type, font_scale, font_color, thickness)

I want to carify each function input so it is clear for people what the input does ...

Transformation

Blur

Resizing

Rotation

Ready Made detection models

http://www.worldlicenseplates.com/world/AF_SUDA.html

Pytesseract OCR

pip install pytesseract

ID card Image

https://www.google.com/search?q=Id+card&tbm=isch&ved=2ahUKEwj7tLqprdPzAhUOwIUKHZlgB4YQ2-cCegQIABAA&oq=Id+card&gs_lcp=CgNpbWcQAzIHCAAQsQMQQzIECAAQQzIICAAQgAQQsQMyBQgAEIAEMgUIABCABDIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQgAQyBAgAEEM6BwgjEO8DECdQmOoBWJzyAWCB-AFoAHAAeACAAYgCiAHwDZIBBTAuMy41mAEAoAEBqgELZ3dzLXdpei1pbWfAAQE&sclient=img&ei=EBdtYfvsGo6AlwSZwZ2wCA&bih=722&biw=1536#imgrc=918MSl3qz45ocM&imgdii=X3ouKQoy4V2bPM

Face Detection

using pretrained models

https://www.analyticsvidhya.com/blog/2018/07/top-10-pretrained-models-get-started-deep-learning-part-1-computer-vision/

https://towardsdatascience.com/darkeras-execute-yolov3-yolov4-object-detection-on-keras-with-darknet-pre-trained-weights-5e8428b959e2

https://learnopencv.com/pytorch-for-beginners-image-classification-using-pre-trained-models/

Haarcascade => https://towardsdatascience.com/face-detection-with-haar-cascade-727f68dafd08

So what is Haar Cascade?

It is an Object Detection Algorithm used to identify faces in an image or a real time video. The algorithm uses edge or line detection features proposed by Viola and Jones in their research paper “Rapid Object Detection using a Boosted Cascade of Simple Features” published in 2001. The algorithm is given a lot of positive images consisting of faces, and a lot of negative images not consisting of any face to train on them.

image.png

https://github.com/opencv/opencv/tree/master/data/haarcascades

Face Detection

https://google.github.io/mediapipe/

mediapipe

pip install mediapipe

Object Detection

PyTorch
pip install torch torchvision
pip install opencv-contrib-python

https://pytorch.org/tutorials/beginner/basics/quickstart_tutorial.html

https://www.pyimagesearch.com/2021/08/02/pytorch-object-detection-with-pre-trained-networks/

AlexNet. It is one of the early breakthrough networks in Image Recognition.

image.png

Next, pre-process the image and prepare a batch to be passed through the network.

output vector out with 1000 elements? We still haven’t got the class (or label) of the image. For this, we will first read and store the labels from a text file having a list of all the 1000 labels

https://gist.github.com/ageitgey/4e1342c10a71981d0b491e1b8227328b

Where to go from here

start searching for pretrained models and use them according to your purpose, the pretrained models have ton of examples online where you can copy portion of code and then, it depends on your undersanding of python and how to use python in your examples and work.

Next level is to start building your network and improve the created models and thier problems, if you didn't use the model you will never be able to improve and add your own work